<template>
  <div class="appPage">
    <!--    <div class="crumbs">-->
    <!--      <el-breadcrumb separator="/">-->
    <!--        <el-breadcrumb-item>-->
    <!--          基础表格-->
    <!--        </el-breadcrumb-item>-->
    <!--      </el-breadcrumb>-->
    <!--    </div>-->
    <h3 class="tit">代理充值记录</h3>
    <div class="search">
      <div class="left">
        <span>代理编号</span>
        <el-input v-model="form.id" placeholder="请输入代理编号" class="handle-input mr10"></el-input>
        <!-- <span>类型</span> -->
        <!--    下拉框    -->
        <!-- <el-select v-model="value" placeholder="请选择">
          <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select> -->

        <el-button type="primary" icon="el-icon-search" @click="handleSearch" class="searchBtn">查找</el-button>
      </div>
      <div class="right">
        <el-button class="reset" type="primary" icon="el-icon-refresh" @click="reset()">重置</el-button>
      </div>
    </div>
   
    <div class="container">
      <el-table
          :data="tableData"
          border
          class="table"
          ref="multipleTable"
          header-cell-class-name="table-header"
          @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center"></el-table-column>
        <el-table-column prop="userId" label="代理编号" align="center"></el-table-column>
        <el-table-column prop="realname" label="代理名称" align="center"></el-table-column>
        <!--        <el-table-column label="账户余额">-->
        <!--          <template #default="scope">￥{{ scope.row.money }}</template>-->
        <!--        </el-table-column>-->
        <el-table-column prop="money" label="充值后余额" align="center"></el-table-column>
        <el-table-column prop="oldMoney" label="充值前余额" align="center"></el-table-column>
        <el-table-column prop="createTime" label="时间" align="center"></el-table-column>
        <el-table-column prop="remarks" label="备注" align="center"></el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination gination
            background
            layout="total, prev, pager, next"
            :current-page="pageIndex"
            :page-size="pageSize"
            :total="pageTotal"
            @current-change="handlePageChange"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios';
export default {
  name: "enterpriseRecharge",
  data() {
    return {
      form: {
        id: null,
        name: "",
        oldMoney: "",
        money: "",
        createTime: "",
      },
      tableData: [],
      pageTotal: 0, //总共有多少数据
      pageIndex: 1,//当前在第几页
      pageSize: 10,//前端规定每页显示数量
      page:1,
      size:10,
      // options: [{
      //   value: '选项1',
      //   label: '充值',
      //   disabled: true
      // }, {
      //   value: '选项2',
      //   label: '划拨'
      // }],
      // value: ''
    };
  },
  created() {
      this.getList();
  },
  //切换界面就执行方法
  activated(){
    this.getList()
  },
  watch:{
      id() {
      
    }
  },
  methods: {
    // 分页导航
    handlePageChange(val) {
        this.page = val;
        this.getList();
    },

    //展示and搜索
    getList(){
      let params ={
        id:this.form.id,
        page: this.page,
        size: this.size, 
      };
      axios.post("http://118.190.2.70:9999/vo/log/userlist",params)
      // axios.post("http://118.190.2.70:9999/vo/log/list",params)
      .then(res =>{
        console.log(res.data.data)
        if(res.data.success == false){
                this.$router.push('/403')
          }else{
               this.tableData = res.data.data
                this.pageTotal = res.data.total
          }
      })
      .catch((err) => {
          console.log(err);
        })
    },

    //重置
    reset(){
      this.form.id = null;
      this.getList();
    },
    //搜索,再次调用getList方法就是展示
    handleSearch(){
      if (this.form.id == "") {
        this.form.id = null;
      }
        this.getList();
    },
  }
};
</script>

<style scoped>

.tit{
  font-weight: normal;
  font-size: 36px;
  color: #333333;
}
.search{
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
.left{
  display: flex;
  align-items: center;
}
.left span{
  width: 120px;
  margin: 10px;
}
.searchBtn{
  margin-left: 15px;
}
.right{
  display: flex;
  justify-content: flex-end;
}
.reset{
  width: 80px;
  height: 34px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.add{
  margin-left: 15px;
}
.container{
  margin-top: 20px;
}
</style>
